#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>

int isTriangleNo(int n)
{
	int t = floor(sqrt(n*2));
	if (t*(t+1) == n*2 || t*(t-1) == n*2) return 1;
	return 0;
}

int main()
{
	FILE *fp;
	fp = fopen("words.txt", "r");
	int i;
	char *words[1786], tmp[20];
	//fscanf(fp, "%s", tmp);
	//printf("%s\n", tmp);
	for (i=0; ; i++) {
		if (fscanf(fp, "%s", tmp) == EOF)break;
		words[i] = (char *)malloc(strlen(tmp)+1);
		strncpy(words[i], tmp, strlen(tmp));		
	}
	fclose(fp);
	int sum = 0, t = 0, j = 0;
	for (i=0; i<1786; i++) {
		t = 0;
		j = 0;
		while (j<strlen(words[i])) {
			t = t + words[i][j++]-'A' + 1;
		}
		if (isTriangleNo(t)) sum++;
	}	
	for (i=0; i<1786; i++) {
		free(words[i]);
		words[i] = NULL;
	}
	printf("%d\n", sum);
}
